﻿Imports System.Data

Partial Class Register
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Dim dpl As New DataProdList
        Dim prodLst As List(Of Product) = dpl.populateArray

        Dim dt As New DataTable()
        Dim dr As DataRow = Nothing
        'Create the Columns Definition
        dt.Columns.Add(New DataColumn("ID", GetType(Integer)))
        dt.Columns.Add(New DataColumn("Description", GetType(String)))
        dt.Columns.Add(New DataColumn("Price", GetType(Double)))
        dt.Columns.Add(New DataColumn("Notes", GetType(String)))

        'HEIR LOOP
        For Each pr As Product In prodLst
            dr = dt.NewRow()
            dr("ID") = pr.getpID
            dr("Description") = pr.getpDesc
            dr("Price") = pr.getpPrc
            dr("Notes") = pr.getpNotes
            dt.Rows.Add(dr)
        Next


        Dim table As New Table()
        Dim row As TableRow = Nothing

        'Add the Headers
        row = New TableRow()
        For j As Integer = 0 To dt.Columns.Count - 1
            Dim headerCell As New TableHeaderCell()
            headerCell.Text = dt.Columns(j).ColumnName
            row.Cells.Add(headerCell)
        Next
        table.Rows.Add(row)

        'Add the Column values
        For i As Integer = 0 To dt.Rows.Count - 1
            row = New TableRow()
            For j As Integer = 0 To dt.Columns.Count - 1
                Dim cell As New TableCell()
                cell.Text = dt.Rows(i)(j).ToString()
                row.Cells.Add(cell)
            Next
            ' Add the TableRow to the Table
            table.Rows.Add(row)
        Next
        ' Add the the Table in the Form
        form1.Controls.Add(table)
    End Sub
End Class
